﻿using Abp.Domain.Repositories;
using Mt.Site.Core.WorkFlows.Process.Entities;
using Mt.Site.Core.WorkFlows.Process.Models;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace Mt.Site.Core.WorkFlows.Process.Stores
{
    /// <summary>
    /// 记录工作流的流转记录
    /// </summary>
    public interface IWorkFlowProcessStore
    {
        IRepository<WorkFlowProcess, Guid> WorkFlowProcessRepository { get; }

        Task<List<WorkFlowProcessDto>> GetAllProcessDataAsync(Guid paperId);
        Task<List<WorkFlowProcessDto>> GetAllProcessDataWithArchiveAsync(Guid paperId);

        Task<List<WorkFlowProcessDto>> GetAllProcessDataAsync(Expression<Func<WorkFlowProcess, bool>> predicate);
        List<WorkFlowProcessDto> GetAllProcessData(Expression<Func<WorkFlowProcess, bool>> predicate);
        /// <summary>
        /// 标记为已读
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task SaveReplyMsgAsync(Guid id, string msg, string customData, bool hasRead, bool isDefaultMsg);

        /// <summary>
        /// 标记为已读
        /// </summary>
        /// <param name="paperId"></param>
        /// <param name="currentUserId"></param>
        /// <returns></returns>
        Task SetHasMarkedAsync(Guid id);

        Task UpdateAsync(WorkFlowProcessDto dto);

        Task InsertAsync(WorkFlowProcessDto dto);

        Task<bool> IsHas(Expression<Func<WorkFlowProcess, bool>> predicate);

        Task RemoveAsync(Expression<Func<WorkFlowProcess, bool>> predicate);

        /// <summary>
        /// 用于自定义操作时的code生成
        /// </summary>
        /// <param name="paperId">稿件id</param>
        /// <param name="trunkId">上级任务id(支线发起人的任务)</param>
        /// <param name="stepCode">当前步骤编号</param>
        /// <returns></returns>
        Task<string> GetLastCodeAsync(Guid paperId, Guid? trunkId, int stepCode);

        Task<List<WorkFlowProcessDto>> GetAllOtherOperatorAsync(Guid paperId, long currentUserId);

        Task<List<WorkFlowProcessMsgDto>> GetAllAdditionalMsgAsync(Guid paperId);

        Task<List<WorkFlowRelationshipDto>> GetWorkFlowRelationshipsAsync(Guid paperId);

        Task<List<WorkFlowRelationshipDto>> GetWorkFlowRelationshipsWithCanceledAAsync(Guid paperId);

        List<WorkFlowRelationshipDto> GetWorkFlowRelationships(Expression<Func<WorkFlowRelationship, bool>> predicate);

        Task SetRelationshipHasMarkedAsync(Guid paperId, Guid TaskId);

        Task TryAddAdditionalMsg(string msg, WorkFlowProcessDto current);

        List<WorkFlowToDoTaskCount> GetAllToDoTaskCount();
    }
}
